<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>答题闯关王</title>
    <link rel="shortcut icon" href="__STATIC__/favicon.ico"/>
    <link href="__STATIC__/css/index/index.css" type="text/css" rel="stylesheet">
	<link href="__STATIC__/layui/css/layui.css" type="text/css" rel="stylesheet">
    <link href="__STATIC__/css/index/iconfont/iconfont.css" type="text/css" rel="stylesheet">
	<script src="__STATIC__/layui/layui.all.js" type="application/javascript"></script>
	<style>
		.desktop .order-box table tbody tr td{
			text-align: center;
		}
	</style>
</head>
<body>
	<div class="desktop item-wrapper">
		<div class="desktop-main">
			<div class="order-box">
				<div class="layui-form-item">
					<button type="button" class="layui-btn layui-btn-sm" onclick="add()" style="float: right;margin-right: 40px; margin-top: 3px;" >
						<i class="layui-icon">&#xe608;</i> 添加
					</button>
				</div>
				<table cellspacing="0" ng-show="docArr.length>0">
					<thead>
						<tr>
							<td>id</td>
							<td>奖品名称</td>
							<td>奖品图片</td>
							<td>奖品所需积分</td>
							<td>每天兑奖数量</td>
							<td>奖品账号</td>
							<td>奖品密码</td>
							<td>操作</td>
						</tr>
					</thead>
					<tbody id="order-table">
					{volist name="rest" id="rest"}
						<tr>
							<td>{$rest['id']}</td>
							<td>{$rest['p_name']}</td>
							<td>
								{if $rest['p_picture']}
								<img src="/static/img/{$rest['p_picture']}" width="50"/>
								{/if}
							</td>
							<td>{$rest['p_integral']}</td>
							<td>{$rest['p_total_awards']}</td>
							<td>{$rest['p_account']}</td>
							<td>{$rest['p_pwd']}</td>
							<td>
								<div class="layui-btn-group">
									<a href="javascript:;" class="update" onclick="update('{$rest['id']}')">
										<i class="layui-icon">&#xe642;</i>
									</a>
									<a href="javascript:;" class="del" onclick="del('{$rest['id']}')">
										<i class="layui-icon">&#xe640;</i>
									</a>
								</div>
							</td>
						</tr>
					{/volist}
					</tbody>
				</table>
				<div style="text-align: center">
					<div id="test1"></div>
				</div>

			</div>
		</div>
	</div>
</body>
<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/js/mao.js"></script>
<script src="/static/js/maowenke.js"></script>
<script>
    function add(){
        layer.closeAll();
        layer.open({
            type: 2,
            title: '添加题目',
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['893px', '600px'],
            content: "{:url('form/addp')}"
			,end:function () {
				window.location.reload();
            }
        });
    }
    /**
	 * 数据分页
     */
    layui.use('laypage', function(){
        var laypage = layui.laypage;

        //执行一个laypage实例
        laypage.render({
            elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
            ,count: parseInt('{$shu}') //数据总数，从服务端得到
			,limit:10
			,jump:function (obj,first) {
				if(!first){
				    $.post('{:url("page/getPrizes")}',{page:obj.curr,limit:10},function (data) {
						    $('tbody').empty();
						    var str = '';
						    $.each(data,function (i,v) {
								str +='<tr>'+
                                    '<td>'+v.id+'</td>'+
                                '<td>'+getStr(v.p_name)+'</td>';
                                str +='<td>'+getImg(v.p_picture)+'</td>'+
                                '<td>'+getStr(v.p_integral)+'</td>'+
                                '<td>'+getStr(v.p_total_awards)+'</td>'+
                                '<td>'+getStr(v.p_account)+'</td>'+
                                '<td>'+getStr(v.p_pwd)+'</td>'+
                                '<td>'+
                                '<div class="layui-btn-group">'+
                                '<a href="javascript:;" class="update" onclick="update('+v.id+')">'+
                                '<i class="layui-icon">&#xe642;</i>'+
                                '</a>'+
                                '<a href="javascript:;" class="del" onclick="del('+v.id+')">'+
                                '<i class="layui-icon">&#xe640;</i>'+
                                '</a>'+
                                '</div>'+
                                '</td>'+
                                '</tr>';
                            });
                            $('tbody').append(str);
                    });
				}
            }
        });
    });
    function update(id) {
        layer.open({
            type: 2,
            title: '修改兑换的奖品',
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['893px', '600px'],
            content: "{:url('prize/show_updata')}?id="+id,
			end:function () {
				window.location.reload();
            }

        });
    }
    function del(id) {
        layer.confirm('你确定要删除吗？',
			{
				btn:['确定','取消']
			},function () {
                $.post("{:url('prize/dele')}",{id:id},function (data) {
                    if(data==1){
                        window.location.reload();
                    }else{
                        layer.msg(data);
                    }
                });
            });
    }
</script>
</html>